# Maintainer: George Rawlinson <grawlinson@archlinux.org>

pkgname=ruby-ice_nine
_pkgname="${pkgname#ruby-}"
pkgver=0.11.2
pkgrel=2
pkgdesc='Deep freeze Ruby objects'
arch=('any')
url='https://github.com/dkubb/ice_nine'
license=('MIT')
depends=('ruby')
makedepends=('git')
options=('!emptydirs')
_commit='2380ec33ef9c3302d0bdf6fb076a5fa6ec9bdc17'
source=("$pkgname::git+$url#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  # latest version has no git tag
  #git describe --tags | sed 's/^v//'
  grep VERSION lib/ice_nine/version.rb | sed -e "s/  VERSION = '\(.*\)'\.freeze/\1/"
}

build() {
  cd "$pkgname"

  gem build "$_pkgname.gemspec"
}

package() {
  cd "$pkgname"

  local _gemdir="$(gem env gemdir)"

  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "$pkgdir/$_gemdir" \
    --bindir "$pkgdir/usr/bin" \
    "$_pkgname-$pkgver.gem"

  # delete cache
  rm -rf "$pkgdir/$_gemdir/cache"

  # license
  install -vd "$pkgdir/usr/share/licenses/$pkgname"
  ln -sf "$_gemdir/gems/$_pkgname-$pkgver/LICENSE" "$pkgdir/usr/share/licenses/$pkgname"
}
